import { fileURLToPath, URL } from 'node:url'
import { resolve } from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

import { createStyleImportPlugin, VxeTableResolve } from 'vite-plugin-style-import';

// 配置elementplus
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    // [
    //   "import",
    //   {
    //     "libraryName": "vxe-table",
    //     "style": true // 样式是否也按需加载
    //   }
    // ],
    createStyleImportPlugin({
      resolves: [VxeTableResolve()],
    }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },

  build: {
    rollupOptions: {
      input: {
        main: resolve(__dirname, 'index.html'),
        student: resolve(__dirname, 'student.html'),
        teacher: resolve(__dirname, 'teacher.html'),
        departmentHead: resolve(__dirname, 'departmentHead.html'),
        superAdministrator: resolve(__dirname, 'super-administrator.html')
      }
    },
    chunkSizeWarningLimit: 1500
  }
})
